<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use app\index\model\Permission as permissionsModel;
class Permission extends Controller
{
  public function save()
  {
      //
  	$name = input('post.name');
  	$permission = new permissionsModel();
  	$permission->name = $name;
  	$permission->save();
  }
  
  public function update()
  {
      //
  	$name = input('post.name');
  	$id = input('post.id');
  	$permission = permissionsModel::get($id);
  	if($name){
  		$permission->name = $name;
  	}
  	$permission->save();
  }
  
  public function query()
  {
      //
  	$id = input('get.id');
  	$permission = permissionsModel::get($id);
  	return json($permission);
  }
  public function queryAll()
  {
  	$permission = permissionsModel::select();
  	return json($permission);
  }
  public function delete()
  {
      //
  	$id = input('get.id');
  	$permission = permissionsModel::get($id);
  	$permission->delete();
  }
}
